var express = require('express');
var router = express.Router();
var connection = require('../connect');

// 获取所有会员卡信息
router.get('/vip', (req, res, next) => {
  connection.query('select * from qn_huiyuanka', (err, r) => {
    if (err) {
      return next(err);
    }
    console.log(r);
    res.send({
      code: 200,
      msg: '成功',
      data: r,
    });
  });
});
router.get('/vipId', (req, res, next) => {
  // 获取get传递的参数
  var obj = req.query;
  // console.log(obj);
  // 执行SQL命令
  connection.query(
    'select * from qn_huiyuanka where cid=?',
    [obj.cid],
    (err, r) => {
      if (err) {
        return next(err);
      }
      console.log(r);
      res.send({ code: 200, msg: '成功', data: r });
    }
  );
});

module.exports = router;
